package com.seventh.associationsystem.service;

import com.seventh.associationsystem.bean.Activity;
import com.seventh.associationsystem.bean.Association;
import com.seventh.associationsystem.repository.ActivityRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

@Service
public class ActivityService {
    @Autowired
    private ActivityRepository activityRepository;

    @Transactional
    public void addActivity(Activity activity) {
        activityRepository.save(activity);
    }

    public List<Activity> getActivities(Association association) {
        return activityRepository.findByAssociationsContaining(association);
    }
}
